#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>

const int N = 1005, inf = 0x3f3f3f3f;
int n, t, f[N], h[N << 1];
int e_cnt = 1, heads[N << 1];

struct Edge {
  int v, nxt, f;
} e[N * N];

inline void add(int u, int v, int f) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].f = f;
  e[++e_cnt].v = u, e[e_cnt].nxt = heads[v], heads[v] = e_cnt, e[e_cnt].f = 0;
}

struct Node {
  int x, y, z;
} a[N];

std::queue<int> q;

inline bool bfs() {
  while (!q.empty()) q.pop();
  q.push(0);
  memset(h, 0, sizeof(h));
  h[0] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = heads[u], v; i; i = e[i].nxt) {
      if (!h[v = e[i].v] && e[i].f) {
        h[v] = h[u] + 1;
        if (v == t) return true;
        q.push(v);
      }
    }
  }
  return false;
}

int dinic(int u, int flow) {
  if (u == t) return flow;
  int rest = flow, k;
  for (int i = heads[u], v; i && rest; i = e[i].nxt) {
    if (h[v = e[i].v] == h[u] + 1 && e[i].f) {
      k = dinic(v, std::min(rest, e[i].f));
      if (!k) h[v] = 0;
      e[i].f -= k, e[i ^ 1].f += k, rest -= k;
    }
  }
  return flow - rest;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("missile.in", "r", stdin);
  freopen("missile.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) { scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z); }
  std::sort(a + 1, a + n + 1,
            [](const Node &lhs, const Node &rhs) { return lhs.x < rhs.x; });
  for (int i = 1; i <= n; ++i) f[i] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < i; ++j) {
      if (a[i].y > a[j].y && a[i].z > a[j].z && a[i].x > a[j].x) {
        add(j, i + n, 1);
        f[i] = std::max(f[i], f[j] + 1);
      }
    }
  }
  int maxx = 0;
  t = n + n + 1;
  for (int i = 1; i <= n; ++i) maxx = std::max(maxx, f[i]);
  for (int i = 1; i <= n; ++i) {
    add(0, i, 1);
    add(i + n, t, 1);
  }
  int ans = 0, flow;
  while (bfs()) {
    while ((flow = dinic(0, inf))) ans += flow;
  }
  printf("%d\n%d", maxx, n - ans);
  return 0;
}